//package org.myrabbitmqdemo.service;
//
//import jakarta.annotation.PostConstruct;
//import jakarta.annotation.Resource;
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.core.MessageProperties;
//import org.springframework.amqp.rabbit.annotation.*;
//import org.springframework.amqp.rabbit.connection.CorrelationData;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.stereotype.Service;
//
///**
// * @author: honry.guan
// * @create: 2025-06-14 07:52
// **/
//@Service
//public class DeadQueueService {
//    @Resource
//    private RabbitTemplate rabbitTemplate;
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(value = "my.normal.queue",
//                    arguments = {
//                            @Argument(name = "x-dead-letter-exchange", value = "my.dead.letter.exchange", type = "String"),
//                            @Argument(name = "x-dead-letter-routing-key", value = "my.dead", type = "String"),
//                            @Argument(name = "x-message-ttl", value = "10000", type = "Integer")
//                    }),
//            exchange = @Exchange(value = "my.normal.exchange", type = "topic"),
//            key = "my.normal"
//    ))
//    public void myDirectClassic(String message) {
//        System.out.println("接收到classic消息：" + message+"抛出有异常生成死信队列");
//        throw new RuntimeException("classic消息处理失败");
//    }
//
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue("my.dead.letter.queue"),
//            exchange = @Exchange(value = "my.dead.letter.exchange", type = "topic"),
//            key = "my.dead"
//    ))
//    public void myDirectQuorum(String message) {
//        System.out.println("收到私信队列消息：" + message);
//    }
//
//    @PostConstruct
//    public void sendMessageWithAsyncCallback() {
//        CorrelationData asyncCorrelation = new CorrelationData( "_async");
//        Message message = new Message("Hello Async Callback".getBytes(), new MessageProperties());
//        rabbitTemplate.send("my.normal.exchange","my.normal.queue", message, asyncCorrelation);
//    }
//}
